package top.infopub.enums.cap;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*费用类型*/
public enum FeeTypeEnum {


    FEE_TYPE0("0", "中收费"),
    FEE_TYPE1("1", "咨询费"),
    FEE_TYPE2("2", "其他");

    private String code;

    private String name;

    FeeTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static FeeTypeEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (FeeTypeEnum pidte : FeeTypeEnum.values()) {
            if (StringUtils.equals(code, pidte.getCode())) {
                return pidte;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (FeeTypeEnum pidte : FeeTypeEnum.values()) {
            map = new HashMap<>();
            map.put("code", pidte.getCode());
            map.put("name", pidte.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
